ENH: add nanmean - #910
Conversation
|
cc @OmarManzoor |
qbarthelemy
left a comment
There was a problem hiding this comment.
Branch must be rebased, because code has been moved to src\array_api_extra\_agnostic\_statistical.py
4eaf451 to
1ba49d5
Compare
applying changes for mean Co-authored-by: Omar Salman <omar.salman@arbisoft.com>
OmarManzoor
left a comment
There was a problem hiding this comment.
LGTM. Thank you @ushnah
|
CC: @lucascolley I think this looks fine to merge |
| safe_count = xp.astype( | ||
| xp.where(count == 0, xp.ones_like(count), count), | ||
| sum_.dtype, | ||
| copy=False, | ||
| ) | ||
| result = sum_ / safe_count | ||
| if xp.any(count == 0): | ||
| result = xp.where( | ||
| count == 0, | ||
| xp.full_like(result, xp.nan), | ||
| result, | ||
| ) |
There was a problem hiding this comment.
why is one of these xp.where calls gated behind xp.any(count == 0), but the other isn't?
There was a problem hiding this comment.
Valid point! Maybe we can just remove this extra condition, the where clause is checking for 0s anyways
|
In case you are interested in contributing another PR @ushnah, checking off the last item in gh-100 would be a good contribution. That would involve following the instructions at https://data-apis.org/array-api-extra/contributing.html#delegation for |
Towards #789